#include "namedPipe.hpp"

int main()
{
    NamedPipe fifo(gPathname, Creater); // read

    // 打开管道
    if (fifo.OpenForRead())
    {
        std::cout << "server open named pipe done" << std::endl;
        while(1)
        {
            std::string out;
            int n = fifo.ReadNamedPipe(&out);
            if (n > 0)
            {
                // 读取成功
                std::cout << "client say->" << out << std::endl;
            }
            else if (n == 0)
            {
                // 写端退出，那么读端也退出
                std::cout << "client quit->server quit,too!" << std::endl;
                break;
            }
            else
            {
                // 出错
                std::cout << "fifo.ReadNamedPipe error" << std::endl;
            }
        }
    }
    return 0;
}